/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.test_finder;

import picounit.Marker;
import picounit.util.Equal;
import picounit.verify.constraint.EqualUtil;

class NoTestsFoundException extends RuntimeException implements Equal<NoTestsFoundException>{
	private static final long serialVersionUID = 1L;

	private final Marker marker;

	public NoTestsFoundException(Marker marker) {
		this.marker = marker;
	}

	public boolean matches(String message, Marker marker) {
		return getMessage().equals(message) &&
			this.marker.equals(marker);
	}

	@Override
	public String getMessage() {
		return marker.getNoneFoundMessage();
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Equal methods
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	public boolean equalTo(NoTestsFoundException other) {
		return other.matches(getMessage(), marker);
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Object methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@Override
	public boolean equals(Object object) {
		return EqualUtil.isEqual(this, object);
	}

	@Override
	public int hashCode() {
		return getMessage().hashCode();
	}
}
